<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/jquery-1.12.4.min.js"></script>
    <script>



        $(function () {
            var $input = $('#input01');
            var $from = $('#from1');



            $input.blur(function () {
                var password_u = /^[\w!@#$]{6,28}$/;
                alert(password_u.test($input.val()));
            })

            $from.submit(function () {
                // 阻止表单提交
                if ($input.val().length < 6) {
                    alert("密码太短");
                    return false;
                }

                return true;

            })

        })
    </script>
</head>
<body>
<form id="from1">
    <label>用户名：</label><input type="text" id="input01" name="username">
    <input type="submit" value="提交">



</form>
</body>
</html>